package com.loveprogrammer.eternity.model.mission.support;

import com.loveprogrammer.eternity.model.Hero;
import com.loveprogrammer.eternity.model.game.HeroWrapper;
import com.loveprogrammer.eternity.model.game.PetWrapper;
import com.loveprogrammer.eternity.model.mission.MissionAction;
import com.loveprogrammer.eternity.model.mission.MissionDefinition;
import com.loveprogrammer.eternity.model.mission.MissionReward;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

/**
 * @version 1.0.0
 * @description: 孵化战宠任务
 * @author: eric
 * @date: 2023-01-05 14:18
 **/
@Data
public class HatchWarPetMission extends MissionDefinition {

    private int monsterId;

    private int goal;

    public HatchWarPetMission(int monsterId, int goal, Integer taskTargetType, MissionReward reward) {
        super(taskTargetType, reward);
        this.monsterId = monsterId;
        this.goal = goal;
    }

    public HatchWarPetMission(String taskId, Integer progress, long createTime, Integer taskTargetType, MissionReward reward, int monsterId, int goal) {
        super(taskId, progress, createTime, taskTargetType, reward);
        this.monsterId = monsterId;
        this.goal = goal;
    }

    @Override
    protected void doUpdate(HeroWrapper hero, MissionAction action) {

        // 查看当前是否已经有了一个对应id的战宠


    }

    @Override
    public boolean checkTaskComplete(HeroWrapper hero) {
        int count = 0;
        // 查看当前是否已经有了一个对应id的战宠
        List<PetWrapper> pets = hero.getPets();
        if(CollectionUtils.isNotEmpty(pets)){
            for (PetWrapper pet : pets) {
                if (pet.getPet().getId() == monsterId) {
                    count++;
                }
            }
        }
        return count >= goal;
    }
}
